package com.example.day7.View;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.example.day7.Model.Bean;
import com.example.day7.Presener.NetPresener;
import com.example.day7.R;

import java.util.ArrayList;

public class PageActivity extends AppCompatActivity {

    private ViewPager page_vp;
    private ImgPAdapter adapter;
    private ArrayList<Bean.DataBean.DatasBean> list;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_page);
        initView();
    }

    private void initView() {

        page_vp = (ViewPager) findViewById(R.id.page_vp);

        list = new ArrayList<>();

        adapter = new ImgPAdapter(list, this);
        page_vp.setAdapter(adapter);

        initData();
    }

    private void initData() {
        NetPresener netPresener = new NetPresener();
        netPresener.initData(new NetView() {
            @Override
            public void getData(Bean bean) {
                adapter.addData(bean.getData().getDatas());
            }
        }, 1);

    }
}
